import { defineStore } from 'pinia'
import request from '../../utils/request'
import { ApiRes, resultType } from '../../types/category'
const initData = [
  { id: '1005000', name: '居家' },
  { id: '1005002', name: '美食' },
  { id: '1010000', name: '服饰' },
  { id: '1011000', name: '母婴' },
  { id: '1013001', name: '个护' },
  { id: '1019000', name: '严选' },
  { id: '1043000', name: '数码' },
  { id: '109243029', name: '运动' },
  { id: '19999999', name: '杂项' }
]

export default defineStore('category', {
  state () {
    return {
      categoryList: initData as resultType[]
    }
  },
  actions: {
    async getCategoryList () {
      ///home/category/head
      const res = await request.request<ApiRes<resultType[]>>({
        url: '/home/category/head'
      })
      this.categoryList = res.data.result
    }
  }
})
